/*  __		__   ___     _____    ____
 *  \ \	   / /  / _ \   |  __ \  |    |
 *   \ \/\/ /  / / \ \  | | / /  |  __|
 *	  \_/\_/  /_/	\_\ |_| \_\  |_|
 *		Take it to the next Level
 *
 *	Copyright (c) 2009 Brian Ernst.
 */

#ifndef w_Vector2
#define w_Vector2

#include <math.h>

namespace _Warp
{
	typedef float Scalar;
	typedef int Bool;

	class Vector2
	{
	public:
		Scalar X;
		Scalar Y;

		Vector2(const Scalar x = 0,const Scalar y = 0);
		~Vector2();

		Vector2 operator+(const Vector2& pVector) const;
		Vector2 operator-(const Vector2& pVector) const;
		Vector2 operator*(const Scalar& num) const;
		Vector2 operator/(const Scalar& num) const;
		Vector2 operator*(const Vector2& vector) const;
		Vector2 operator/(const Vector2& vector) const;
		void operator+=(const Vector2& pVector);
		void operator-=(const Vector2& pVector);
		void operator*=(const Scalar& num);
		void operator/=(const Scalar& num);
		void operator=(const Vector2& pVector);
		Bool operator==(const Vector2& vector) const;
		Bool operator!=(const Vector2& vector) const;

		void Clamp(const Scalar& value);
		void Normalize(const Scalar& value = 1.0f);
		void Invert();

		Scalar Length() const;

		Vector2 Copy() const;

		static Vector2 Cartesian(const Scalar& x,const Scalar& y);
		static Vector2 Polar(const Scalar& radius,const Scalar& angle);
		static Scalar Dot(const Vector2& pVec1,const Vector2& pVec2);
		static Vector2 Rotate(const Vector2& pVec,const Scalar& angle);
		static const Vector2 Zero;
	};

	inline Vector2 Vector2::Copy() const
	{
		return Vector2(X,Y);
	}

	inline Bool Vector2::operator==(const Vector2& vector) const
	{
		return X == vector.X && Y == vector.Y;
	}

	inline Bool Vector2::operator!=(const Vector2& vector) const
	{
		return X != vector.X || Y != vector.Y;
	}

	inline Vector2 Vector2::operator+(const Vector2& pVector) const
	{
		return Vector2(X + pVector.X,Y + pVector.Y);
	}

	inline Vector2 Vector2::operator-(const Vector2& pVector) const
	{
		return Vector2(X - pVector.X,Y - pVector.Y);
	}

	inline Vector2 Vector2::operator*(const Scalar& num) const
	{
		return Vector2(X * num,Y * num);
	}

	inline Vector2 Vector2::operator/(const Scalar& num) const
	{
		return Vector2(X / num,Y / num);
	}

	inline Vector2 Vector2::operator*(const Vector2& vector) const
	{
		return Vector2(X * vector.X,Y * vector.Y);
	}

	inline Vector2 Vector2::operator/(const Vector2& vector) const
	{
		return Vector2(X / vector.X,Y / vector.Y);
	}
}

#endif
